home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / os2 / adaptor.zip / ADAPT.ZIP / adaptor / src / include / sets.h < prev    next >
C/C++ Source or Header  |  1993-03-22  |  3KB  |  95 lines

  1. # ifndef yySets
  2. # define yySets
  3.  
  4. /* $Id: Sets.h,v 1.6 1992/02/06 09:29:54 grosch rel $ */
  5.  
  6. /* $Log: Sets.h,v $
  7.  * Revision 1.6  1992/02/06  09:29:54  grosch
  8.  * fixed bug: stdio and ANSI C
  9.  *
  10.  * Revision 1.5  1991/11/21  14:25:34  grosch
  11.  * new version of RCS on SPARC
  12.  *
  13.  * Revision 1.4  91/07/17  17:23:38  grosch
  14.  * introduced ARGS trick for ANSI compatibility
  15.  * 
  16.  * Revision 1.3  90/07/04  14:34:05  grosch
  17.  * introduced conditional include
  18.  * 
  19.  * Revision 1.2  89/12/08  17:25:03  grosch
  20.  * complete redesign in order to increase efficiency
  21.  * 
  22.  * Revision 1.1  89/01/09  17:29:42  grosch
  23.  * added functions Size, Minimum, and Maximum
  24.  * 
  25.  * Revision 1.0  88/10/04  11:44:45  grosch
  26.  * Initial revision
  27.  * 
  28.  */
  29.  
  30. /* Ich, Doktor Josef Grosch, Informatiker, Sept. 1987 */
  31.  
  32. # include "ratc.h"
  33. # include <stdio.h>
  34.  
  35. # ifdef __STDC__
  36. # define ARGS(parameters)    parameters
  37. # else
  38. # define ARGS(parameters)    ()
  39. # endif
  40.  
  41. # define BitsPerBitset        32
  42. # define LdBitsPerBitset    5
  43. # define MaskBitsPerBitset    0x0000001f
  44.  
  45. # define IsElement(Elmt, Set)    ((int) ((Set)->BitsetPtr [(Elmt) >> LdBitsPerBitset] << ((Elmt) & MaskBitsPerBitset)) < 0)
  46. # define Size(Set)    ((Set)->MaxElmt)
  47. # define Select(Set)    Minimum (Set)
  48. # define IsNotEqual(Set1, Set2)    (! IsEqual (Set1, Set2))
  49. # define IsStrictSubset(Set1, Set2) (IsSubset (Set1, Set2) && IsNotEqual (Set1, Set2))
  50.  
  51. typedef long    BITSET        ;
  52.  
  53. typedef struct    {
  54.       cardinal    MaxElmt        ;
  55.       cardinal    LastBitset    ;
  56.       BITSET *    BitsetPtr    ;
  57.       short    Card        ;
  58.       cardinal    FirstElmt    ;
  59.       cardinal    LastElmt    ;
  60.    } tSet;
  61.  
  62. extern void    MakeSet        ARGS((tSet * Set, cardinal MaxSize));
  63. extern void    ReleaseSet    ARGS((tSet * Set));
  64. extern void    Union        ARGS((tSet * Set1, tSet * Set2));
  65. extern void    Difference    ARGS((tSet * Set1, tSet * Set2));
  66. extern void    Intersection    ARGS((tSet * Set1, tSet * Set2));
  67. extern void    SymDiff        ARGS((tSet * Set1, tSet * Set2));
  68. extern void    Complement    ARGS((tSet * Set));
  69. extern void    Include        ARGS((tSet * Set, cardinal Elmt));
  70. extern void    Exclude        ARGS((tSet * Set, cardinal Elmt));
  71. extern cardinal    Card        ARGS((tSet * Set));
  72. /* extern cardinal    Size        ARGS((tSet * Set)); */
  73. extern cardinal    Minimum        ARGS((tSet * Set));
  74. extern cardinal    Maximum        ARGS((tSet * Set));
  75. /* extern cardinal    Select        ARGS((tSet * Set)); */
  76. extern cardinal    Extract        ARGS((tSet * Set));
  77. extern bool    IsSubset    ARGS((tSet * Set1, tSet * Set2));
  78. /* extern bool    IsStrictSubset    ARGS((tSet * Set1, tSet * Set2)); */
  79. extern bool    IsEqual        ARGS((tSet * Set1, tSet * Set2));
  80. /* extern bool    IsNotEqual    ARGS((tSet * Set1, tSet * Set2)); */
  81. /* extern bool    IsElement    ARGS((cardinal Elmt, tSet * Set)); */
  82. extern bool    IsEmpty        ARGS((tSet * Set));
  83. extern bool    Forall        ARGS((tSet * Set, bool (* Proc) ()));
  84. extern bool    Exists        ARGS((tSet * Set, bool (* Proc) ()));
  85. extern bool    Exists1        ARGS((tSet * Set, bool (* Proc) ()));
  86. extern void    Assign        ARGS((tSet * Set1, tSet * Set2));
  87. extern void    AssignElmt    ARGS((tSet * Set, cardinal Elmt));
  88. extern void    AssignEmpty    ARGS((tSet * Set));
  89. extern void    ForallDo    ARGS((tSet * Set, void (* Proc) ()));
  90. extern void    ReadSet        ARGS((FILE * File, tSet * Set));
  91. extern void    WriteSet    ARGS((FILE * File, tSet * Set));
  92. extern void    InitSets    ();
  93.  
  94. # endif
  95.